package ckw.database.repositories;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import ckw.database.model.Voter;

@Transactional
public interface VoterRepository extends JpaRepository<Voter, Long> {

	Voter findByIdentificationField(String identificationField);

	@Query("FROM Voter v WHERE LOWER(v.name) LIKE :text OR LOWER(v.surname) LIKE :text OR LOWER(v.address) LIKE :text OR LOWER(v.identificationField) LIKE :text")
	List<Voter> findAllLike(@Param("text") String text);

}
